﻿@model UMS.Web.ViewModels.ChangePassword
@{
    Layout = "_Me.cshtml";
    ViewBag.Title = "My Password";
    var u = ViewData["User"] as UMS.Core.Data.Models.Directory.User;
}
@section Head
{
    @Styles.Render("~/bundles/css/jquery")
}
<div class="box">
    <div class="head">
        My Password
    </div>
    <p>
        @{
            if (u.PasswordExpiresOn == DateTime.MaxValue)
            {
            @MvcHtmlString.Create(u.FirstName + ", your password never expires.")
            }
            else if (u.PasswordExpiresOn == DateTime.MinValue || u.PasswordExpiresOn <= DateTime.UtcNow)
            {
            @MvcHtmlString.Create("<span style=\"color: red; font-weight: bold;\">" + u.FirstName + ", your password has expired!</span>")
            }
            else
            {
            @MvcHtmlString.Create(u.FirstName + ", your password expires <abbr class=\"timeago\" title=\""
                                            + String.Format("{0:s}", u.PasswordExpiresOn)
                                            + "\"></abbr>.")
            }
        }
    </p>
    @using (Html.BeginForm("Password", "Me", Model, FormMethod.Post, new { id = "PasswordChange" }))
    {
        @Html.EditorForModel()
        <input type="submit" value="Save Changes" />
    }
</div>
@section Script
{
    <script type="text/javascript">
        $(function () {
            $("abbr.timeago").timeago();
            $("#PasswordChange").makeValidationInline();
        })
    </script>
}
